<!--开启页面选项卡后，显示为选项卡标题-->
<title>修改密码</title>

<div class="layui-card layadmin-header">
  <div class="layui-breadcrumb" lay-filter="breadcrumb">
    <a><cite>我的</cite></a>
    <a><cite>修改密码</cite></a>
  </div>
</div>

<div class="layui-fluid">
  <div class="layui-row layui-col-space15">
    <div class="layui-col-md12">
      <div class="layui-card">
        <div class="layui-card-header">修改密码</div>
        <div class="layui-card-body" pad15>
          <div class="layui-form" lay-filter="">
            <div class="layui-form-item">
              <label class="layui-form-label">当前密码</label>
              <div class="layui-input-inline">
                <input type="password" name="old_password" lay-verify="required" lay-verType="tips" class="layui-input">
              </div>
            </div>
            <div class="layui-form-item">
              <label class="layui-form-label">新密码</label>
              <div class="layui-input-inline">
                <input type="password" name="new_password" lay-verType="tips" autocomplete="off" lay-verify="required" id="LAY_password" class="layui-input">
              </div>
            </div>
            <div class="layui-form-item">
              <label class="layui-form-label">确认新密码</label>
              <div class="layui-input-inline">
                <input type="password" name="verify_password" lay-verType="tips" autocomplete="off" lay-verify="required" lay-reqtext="请再次输入新密码" class="layui-input">
              </div>
            </div>
            <div class="layui-form-item">
              <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="LAY-password-submit">确认修改</button>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>

<script>
  layui.use(['form', 'admin'], function () {
    let form = layui.form
        , admin = layui.admin;
    form.on('submit(LAY-password-submit)', function (data) {
      let field = data.field;
      if (field.new_password !== field.verify_password) {
        layer.msg('两次输入的密码不一致');
        return;
      }
      admin.post('lay-admin/changePassword', field, function (res) {
        layer.msg('密码修改成功');
      })
    });
  });
</script>